      <div class="templatemo-content-wrapper">
        <div class="templatemo-content">
          <ol class="breadcrumb">
            <li><a href="<?=site_url()?>/product/index">商品管理</a></li>
            <li class="active">下架商品</li>
          </ol>
           <div class="row margin-bottom-10">
           <div class="col-md-12">
              <ul class="nav nav-pills">
              	<li class="active"><a href="<?=site_url()?>/product/shelves/show/0">查看所有下架商品</a></li>
                 <li class="active"><a href="<?=site_url()?>/product/shelves/show/1">查看已下架未上架商品</a></li>
              </ul>          
           </div>
           </div> 
          <div class="row">
            <div class="col-md-12">
              <div class="table-responsive">
                <h4 class="margin-bottom-15">下架商品记录</h4>
                <table class="table table-striped table-hover table-bordered">
                  <thead>
                    <tr>
                      <th>ID</th>
                      <th>商品名称</th>
                      <th>操作日期</th>
                      <th>状态</th>
                    </tr>
                  </thead>
                  <tbody>
                  	<?php foreach ($shelves as $item):?>
                    <tr>
                      <td><?php echo $item['id'];?></td>
                      <td><?php echo $item['name'];?></td>
                      <td><?php echo $item['date'];?></td>
                      <td>
                      		<?php 
                      		if($item['show']==1){
                      				echo "已上架";
                      		}else{
                  					echo "已下架";
									echo '<a href="" class="btn btn-link showpro" data-id="'.$item['productid'].'" >上架</a>';
                      		}?>
                      </td>
                    </tr>
                     <?php endforeach;?>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
           <div class="pagination">
            <?php echo $links ;?>
          </div>
        </div>
      </div>
       <script>
	$(document).ready(function() {
		$(".showpro").click(function() {
			if(confirm("确定要上架吗？"))
			{
			var productid = $(this).attr("data-id");
			$.ajax({
				url : '<?php echo site_url('product/setproductstate')?>',
				type : "post",
				async : false,
				data : {
					'productid' : productid,
					'state':1
				},
				dataType : "json",
				success : function(data) {
					if(data.code)
					{
						alert(data.msg);
						window.location.reload();
					}else{
						alert(data.msg);
					}
				}
			});
			}
			
		});
	}); 
</script>